<template>
  <el-dialog
    title="领用详情"
    :visible="moreDialog"
    width="60%"
    @close="$emit('close')"
    append-to-body
  >
    <!-- 进度 -->
    <el-steps class="steps" simple :active="activeStatus" align-center>
      <el-step title="待审批" icon="el-icon-edit" />
      <el-step
        v-for="(item, i) in info.reviewer"
        :key="i"
        icon="el-icon-edit"
        :title="`${item.name}审核`"
        :description="item.resone"
      />
      <el-step
        v-if="info.status === 3"
        icon="el-icon-circle-close"
        title="未通过"
      />
      <template
        v-else-if="info.status === 1 || info.status === 2 || info.status === 0|| info.status === 5"
      >
        <el-step icon="el-icon-circle-check" title="待领用" />
        <el-step icon="el-icon-circle-check" title="已领用" />
      </template>
      <el-step
        v-else-if="info.status === 4"
        icon="el-icon-circle-close"
        title="已取消"
      />
      <el-step
        v-else-if="info.status === 6"
        icon="el-icon-circle-check"
        title="已归还"
      />
    </el-steps>
    <!-- 未通过原因 -->
    <div v-if="info.status === 3" class="reason">
      <span>未通过原因:</span>
      <div v-for="(item, i) in info.reviewer" :key="i">
        <span>{{ item.name }}:</span>
        <div>
          {{ item.resone ? item.resone :'无' }}
        </div>
      </div>
    </div>
    <!-- 物品列表 -->
    <el-table :data="info.store" style="width: 100%">
      <el-table-column type="index" label="序号" width="55" align="center" />
      <el-table-column prop="name" label="物料名称"  align="center" />
      <el-table-column label="类别" align="center" :formatter="typeFormatter"/>
      <el-table-column label="类型" align="center" :formatter="categoryFormatter"/>
      <el-table-column prop="num" label="数量"  align="center" />
      <el-table-column prop="unit" label="单位" align="center"/>
    </el-table>

    <span slot="footer" class="dialog-footer">
      <el-button class="btn" type="primary" @click="$emit('close')">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    moreDialog: {
      type: Boolean,
      default: false
    },
    info: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {}
  },
  computed: {
    activeStatus() {
      const reviewerNumb = this.info.reviewer.length
      if (this.info.status === 0) {
        const index = this.info.reviewer.findIndex(item => item.isPass === 0)
        if (index == -1) return 1 + reviewerNumb
        else return 1 + index
      } else if (
        this.info.status === 1
      ) {
        return 1 + reviewerNumb
      } else if (this.info.status === 2||
        this.info.status === 4||
        this.info.status === 3) {
        return 2 + reviewerNumb
      }else {
        return 3 + reviewerNumb
      }
    }
  },

  created() {},

  methods: {
    typeFormatter(row){
       if(row.type == 1){
        return '器材'
       }else if(row.type == 2){
        return '标准物质'
       }else {
        return '化学试剂'
       }
    },
    categoryFormatter(row){
       if(row.type == 1){
        if(row.category == 1){
          return '玻璃器皿'
        }else if(row.category == 2){
          return '实验耗材'
        }else if(row.category == 3){
          return '采样工具'
        }else{
          return '仪器设备'
        }
       }else if (row.type == 2){
        return row.category
       }else if (row.type == 3){
        return '/'
       }
    },
  }
}
</script>

<style scoped lang="scss">
.steps ::v-deep{
  font-size: 18px;
  height: 70px;
  .el-step.is-simple[data-v-68c18825] .el-step__title{
    font-size: 16px;
  }
}
.el-table {
  margin-top: 30px;
  font-size: 16px;
}
.el-table ::v-deep th.el-table__cell {
  background-color: #5a9cf8;
  color: #fff;
}

.el-step.is-simple ::v-deep .el-step__title {
  font-size: 14px;
}
.reason {
  font-size: 16px;
  padding: 5px;
  margin-top: 10px;
  background-color: #f5f7fa;
  min-height: 50px;
  >div {
    display: flex;
    padding: 10px;
    span {
      width: 80px;
      text-align: right;
      margin-right: 15px;
    }
  }
}
.btn {
  height: 40px;
  font-size: 16px;
}
</style>
